<div class="container">
	<form action="aaa" class="form-inline">
		<div class="form-group" style="margin-top: 20px">
			<label>选择班级：</label> 
			<span><input class="form-control" name="banji" id="banji" type="text" /></span>
		</div>
		<div class="form-group" style="margin-top: 20px">
			<label>选择学生：</label>
			<span> <input class="form-control" name="stu" id="stu" type="text" disabled="false" /></span>
		</div>
		<div class="form-group" style="margin-top: 20px; margin-left: 50px;">
			<button type="button" class="btn btn-default"  id="cx">查询</button>
		</div>
	</form>
	<div id="table" style="display: none;">
		<table id="mytable">
			<thead>
				<tr>
				 <th data-field='student.stuNo'>学号</th>
				 <th data-field='student.namee'>姓名</th>
				 <th data-field='course.name'>课程</th>
				 <th data-field='grade' formatter='formatOper(val,row,index)'>成绩</th>
				</tr>
			</thead>
		</table>
	</div>
</div>
<script type="text/javascript">
	$(function(){
		$('#banji').combobox({
			url:'banji/list',
			valueField:'id',
			textField:'name',
			onchange:function(newVal){
				$('#stu').combobox('destroy');
				$('#stu').combobox({
					textField:'name',
					valueField:'id',
					url:'grade/stu?bjId='+newVal
				})
			}
		})
		
		var grid=$('#mytable');
		$('#cx').bind('click',function(){
			var stuId=$('#stu').combobox('getValue');
			var bjId=$('#banji').combobox('getValue');
			if(bjId==null||stuId==0){
				$('#table').hide();
				return;
			}else{
				$('#table').show();
			}
			grid.datagrid({
				url:'grade/getGrade?stuId='+stuId,
				search:false,
				buttons:[],
				pagination: false, 
				columns:[
					[
						{title:'abc',field:'abc',checkbox:true}, 
						{field:'student.tbClass.name',title:'班级'},
						{field:'student.stuNo',title:'学号'},
						{field:'student.name',title:'姓名'},
						{field:'course.name',title:'课程'},
						{field:'grade.name',title:'成绩',formatter:function formatOper(val,row,index){
							if(row.grade==null){
								row.grade=0;
							}
							return '<input type="number" class="form-control" onchange="xg('+row.id+',value)" id="input" value="'+row.grade+'"/>';
						}}
						
					]
				],
			});
			
		});
	})
	function xg(id,grade){
		$.post('grade/save',{id:id,grade:grade},function(data){});
	}
	
</script>